<!-- -->
<template>
  <div class="public">
    <el-card>
      <SearchTable @search="getSearchData" :page="searchPage" v-model="searchData" />
      <div class="table">
        <el-table :data="tableData" style="width: 100%">
          <el-table-column label="序号" type="index"></el-table-column>
          <el-table-column label="小区名称" prop="housingName"></el-table-column>
          <el-table-column label="标题" prop="listingTitle"></el-table-column>
          <el-table-column label="面积" prop="houseArea"></el-table-column>
          <el-table-column label="总价" prop="sellingprice"></el-table-column>
          <el-table-column label="排序" prop="pv"></el-table-column>
          <el-table-column label="状态" prop="date">
            <template slot-scope="scope">
              <div v-if="scope.row.isShow === '0'">待审核</div>
            </template>
          </el-table-column>
          <el-table-column label="操作" prop="name" class="btn">
            <template slot-scope="scope">
              <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
              <el-button type="text" size="small" @click="del(scope.row.id)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-card>

    <!-- <div class="page">
      <el-pagination
        background
        layout="prev, pager, next"
        :total="total*1"
        :current-page.sync="nowPage"
        @current-change="changePage"
    ></el-pagination>-->
    <!-- </div> -->
  </div>
</template>

<script>
import SearchTable from "@/components/SearchTable";
import { getnewoldhouse, delnewoldhouse, searchOldList } from "@/api";
export default {
  // import引入到组件需要注入到对象中才能使用
  components: { SearchTable },
  data() {
    // 这里存放数据
    return {
      searchData: {},
      searchPage: [
        {
          lable: "地区",
          type: "city",
          value: {
            province: "province",
            city: "city",
            area: "area"
          }
        },
        {
          lable: "搜索",
          type: "input",
          value: "value",
          placeholder: "请输入关键字"
        }
      ],
      tableData: [],
      value: "",
      con: ""
    };
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监听data中的数据变化
  watch: {},
  // 方法集合
  methods: {
    getList() {
      getnewoldhouse().then(res => {
        this.tableData = res.data;
      });
    },
    getSearchData(data) {
      this.con = data.value;
      searchOldList({ value: this.con }).then(res => {
        this.tableData = res.data;
      });
    },
    // 删除按钮
    del(id) {
      delnewoldhouse({ id }).then(res => {
        this.getList();
      });
    }
  },
  //生命周期 - 创建完成 (可以访问当前this实例)
  created() {
    this.getList();
  },
  //生命周期 - 挂载完成 (可以访问DOM元素)
  mounted() {}
};
</script> 

<!-- Add "scoped" attribute to limit CSS to this component only -->
<!--使用了scoped属性之后，父组件的style样式将不会渗透到子组件中，-->
<!--然而子组件的根节点元素会同时被设置了scoped的父css样式和设置了scoped的子css样式影响，-->
<!--这么设计的目的是父组件可以对子组件根元素进行布局。-->
<style lang='scss'  scoped>
.public {
  padding: 20px 38px;
}
.table {
  margin-top: 20px;
}
</style>
